const { MOCK } = require('../utils').settings
const axios = require('../utils/axios')
const { error } = require('../utils/error')
const { mockAuthorInfo, mockAuthorDynamic } = require('./mock/author')
const apiError = (msg) => {
  error('50000', __filename, msg)
}
// user - AuthorInfo
exports.requestAuthorInfo = async (data = {}) => {
  let result = MOCK
    ? mockAuthorInfo
    : await axios.get('/user/getOtherUserDate', {
        params: data
      })
  // let result = await mockAuthorInfo
  if (!result) {
    apiError('requestAuthorInfo')
    result = mockAuthorInfo
  }
  return result
}

// user - dynamic
exports.requestAuthorDynamic = async (data = {}) => {
  let result = MOCK
    ? mockAuthorDynamic
    : await axios.get('/user/getUserAction', {
        params: data
      })
  // let result = await mockDynamic
  if (!result) {
    apiError('requestAuthorDynamic')
    result = mockAuthorDynamic
  }
  return result
}
